package one.stand.controller;

import com.jmp.autocofiguration.web.interceptor.SecurityAuthCheck;
import com.jmp.base.dto.ImChatPageRequest;
import com.jmp.base.dto.ImChatPageResponse;
import com.jmp.base.dto.ImRequest;
import com.jmp.base.dto.ImSendRequest;
import com.jmp.feign.ImFeign;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import one.stand.model.ResultModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * User: yandou
 * Date: 2019/11/25
 * Time: 3:29 下午
 * Description: No Description
 */
@Api("im")
@RestController
@RequestMapping("/im")
public class ImController extends BaseController {

    @Autowired
    private ImFeign imFeign;

    @ApiOperation(value = "发送消息")
    @PostMapping("/send")
    @SecurityAuthCheck(company = true, card = true)
    public ResultModel send(@RequestAttribute ImSendRequest request) {
        return imFeign.imSend(request);
    }

    @ApiOperation(value = "获取聊天列表")
    @PostMapping("/chat")
    @SecurityAuthCheck(company = true, card = true)
    public ResultModel imChat(@RequestAttribute ImRequest request) {
        return imFeign.imChat(request);
    }

    @ApiOperation(value = "获取聊天列表，分页")
    @PostMapping("/chat/page")
    @SecurityAuthCheck(company = true, card = true)
    public ResultModel<ImChatPageResponse> chatPage(@RequestAttribute ImChatPageRequest request) {
        return imFeign.chatPage(request);
    }

    @ApiOperation(value = "获取聊天内容")
    @PostMapping("/chat/content")
    @SecurityAuthCheck(company = true, card = true)
    public ResultModel imChatContent(@RequestAttribute ImRequest request) {
        return imFeign.imChatContent(request);
    }
}
